import { request } from '../request';

const URL = {
    LOGIN: '/common/login',
    REGISTER: '/common/register',
    SEND_VERIFY_CODE: '/common/sendVerifyCode',
    LOGOUT: '/user/logout',
    USER_INFO: '/user/getUserInfo'
};

/** 登录 */
export function fetchLogin(params: User.Login) {
    return request.post(URL.LOGIN, params);
}

/** 登出 */
export function fetchLogout() {
    return request.get(URL.LOGOUT);
}

/** 获取用户信息 */
export function fetchGetUserInfo() {
    return request.get(URL.USER_INFO);
}

/** 注册 */
export function fetchRegister(params: User.Register) {
    return request.post(URL.REGISTER, params);
}

/** 发送验证码 */
export function fetchSendVerifyCode(params: string) {
    return request.post(URL.SEND_VERIFY_CODE, { email: params });
}
